WPS Office.apk(点击下载) / ofa.java


package defpackage;

import cn.wps.moffice.writer.core.TextDocument;
import org.apache.commons.httpclient.cookie.CookiePolicy;

/* renamed from: ofa  reason: default package */
public final class ofa {
    public static String Vr(int i) {
        String hexString = Integer.toHexString(i);
        StringBuffer stringBuffer = new StringBuffer();
        if (i < 16) {
            stringBuffer.append("0");
        }
        stringBuffer.append(hexString);
        return stringBuffer.toString();
    }

    public static String a(mzf mzf, int i) {
        ew.assertNotNull("info should not be null!", mzf);
        byte[] bArr = mzf.pvp;
        int i2 = i + 1;
        int i3 = i2 + 1;
        String hexString = Integer.toHexString(Integer.valueOf(((bArr[i3 + 1] & 255) << 24) + ((bArr[i3] & 255) << 16) + ((bArr[i2] & 255) << 8) + (bArr[i] & 255)).intValue());
        StringBuffer stringBuffer = new StringBuffer();
        int length = 8 - hexString.length();
        for (int i4 = 0; i4 < length; i4++) {
            stringBuffer.append('0');
        }
        stringBuffer.append(hexString);
        return stringBuffer.toString().toUpperCase();
    }

    public static void b(ode ode, abfo abfo) {
        ew.assertNotNull("context should not be null!", ode);
        ew.assertNotNull("doc should not be null!", abfo);
        TextDocument textDocument = ode.pxJ;
        ew.assertNotNull("textDocument should not be null!", textDocument);
        mdw mdw = textDocument.oRe;
        ew.assertNotNull("coreFontTable should not be null!", mdw);
        int size = mdw.size();
        abfr f = abfr.f(abfo);
        odf odf = new odf(f.BVU.getOutputStream(), f);
        odf.i("w:fonts", "xmlns:mc", "http://schemas.openxmlformats.org/markup-compatibility/2006", "xmlns:r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships", "xmlns:w", "http://schemas.openxmlformats.org/wordprocessingml/2006/main", "xmlns:w14", "http://schemas.microsoft.com/office/word/2010/wordml", "mc:Ignorable", "w14");
        for (int i = 0; i < size; i++) {
            mzf Nz = mdw.Nz(i);
            ew.assertNotNull("w should not be null!", odf);
            ew.assertNotNull("info should not be null!", Nz);
            String str = Nz.mFontName;
            ew.assertNotNull("name should not be null!", str);
            if (!hx.f(str)) {
                odf.i("w:font", "w:name", Nz.mFontName);
                String str2 = Nz.pve;
                if ("WPS Special 1".equalsIgnoreCase(str) || "WPS Special 2".equalsIgnoreCase(str) || "WPS Special 3".equalsIgnoreCase(str)) {
                    StringBuilder sb = new StringBuilder();
                    int length = str2.length();
                    for (int i2 = 0; i2 < length; i2++) {
                        char charAt = str2.charAt(i2);
                        sb.append("&#");
                        sb.append(Integer.toString(charAt));
                        sb.append(";");
                    }
                    String sb2 = sb.toString();
                    if (sb2.length() > 0) {
                        odf.k("w:altName", "w:val", sb2);
                    }
                } else {
                    odf.j("w:altName", "w:val", str2);
                }
                ew.assertNotNull("info should not be null!", Nz);
                StringBuffer stringBuffer = new StringBuffer();
                stringBuffer.append(Vr(Nz.pvf));
                stringBuffer.append(Vr(Nz.pvg));
                stringBuffer.append(Vr(Nz.pvh));
                stringBuffer.append(Vr(Nz.pvi));
                stringBuffer.append(Vr(Nz.pvj));
                stringBuffer.append(Vr(Nz.pvk));
                stringBuffer.append(Vr(Nz.pvl));
                stringBuffer.append(Vr(Nz.pvm));
                stringBuffer.append(Vr(Nz.pvn));
                stringBuffer.append(Vr(Nz.pvo));
                odf.j("w:panose1", "w:val", stringBuffer.toString());
                short s = Nz.pvd;
                StringBuffer stringBuffer2 = new StringBuffer();
                stringBuffer2.append(Vr(s));
                odf.j("w:charset", "w:val", stringBuffer2.toString());
                String[] strArr = new String[2];
                strArr[0] = "w:val";
                byte b = Nz.dPP;
                StringBuffer stringBuffer3 = new StringBuffer();
                switch (b) {
                    case 0:
                        stringBuffer3.append("auto");
                        break;
                    case 1:
                        stringBuffer3.append("roman");
                        break;
                    case 2:
                        stringBuffer3.append("swiss");
                        break;
                    case 3:
                        stringBuffer3.append("modern");
                        break;
                    case 4:
                        stringBuffer3.append("script");
                        break;
                    case 5:
                        stringBuffer3.append("decorative");
                        break;
                    default:
                        ew.eI();
                        stringBuffer3.append("auto");
                        break;
                }
                strArr[1] = stringBuffer3.toString();
                odf.j("w:family", strArr);
                String[] strArr2 = new String[2];
                strArr2[0] = "w:val";
                byte b2 = Nz.pva;
                StringBuffer stringBuffer4 = new StringBuffer();
                switch (b2) {
                    case 0:
                        stringBuffer4.append(CookiePolicy.DEFAULT);
                        break;
                    case 1:
                        stringBuffer4.append("fixed");
                        break;
                    case 2:
                        stringBuffer4.append("variable");
                        break;
                    default:
                        ew.eI();
                        stringBuffer4.append(CookiePolicy.DEFAULT);
                        break;
                }
                strArr2[1] = stringBuffer4.toString();
                odf.j("w:pitch", strArr2);
                if (Nz.pvp != null) {
                    odf.j("w:sig", "w:usb0", a(Nz, 0), "w:usb1", a(Nz, 4), "w:usb2", a(Nz, 8), "w:usb3", a(Nz, 12), "w:csb0", a(Nz, 16), "w:csb1", a(Nz, 20));
                }
                odf.endElement("w:font");
            }
        }
        odf.endElement("w:fonts");
        odf.close();
        f.BVU.close();
    }
}